forked from thoughtpolice/bcachefs-tools
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging and exiting #309
Merged
koverstreet
merged 3 commits into
koverstreet:master
from
tmuehlbacher:improve-logging-exiting
Jun 29, 2024
Merged
Improve logging and exiting #309
koverstreet
merged 3 commits into
koverstreet:master
from
tmuehlbacher:improve-logging-exiting
Jun 29, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tmuehlbacher
force-pushed
the
improve-logging-exiting
branch
2 times, most recently
from
June 28, 2024 19:18
81684ff
to
949dde8
Compare
Instead of the custom logger impl, which limits the features we can easily provide for users. This introduces the `BCACHEFS_LOG` environment variable for setting the log verbosity. Setting `BCACHEFS_LOG=trace`, e.g. in a test environment, will yield all log messages. Also I think it's reasonable to print INFO level logs by default. Signed-off-by: Thomas Mühlbacher <[email protected]>
To silence log outputs on the CLI. Signed-off-by: Thomas Mühlbacher <[email protected]>
Should provide us with better outputs on process failure, also makes unwinding better and is generally recommended over `exit()`. Signed-off-by: Thomas Mühlbacher <[email protected]>
tmuehlbacher
force-pushed
the
improve-logging-exiting
branch
from
June 29, 2024 17:41
949dde8
to
5cce07e
Compare
$ tokei env_logger-0.10.2 is-terminal-0.4.12 termcolor-1.4.1
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
TOML 4 249 189 30 30
-------------------------------------------------------------------------------
Markdown 3 284 0 195 89
|- BASH 2 41 37 0 4
|- Rust 3 73 58 1 14
|- TOML 1 5 4 0 1
(Total) 403 99 196 108
-------------------------------------------------------------------------------
Rust 27 5872 4854 353 665
|- Markdown 9 1528 11 1112 405
(Total) 7400 4865 1465 1070
===============================================================================
Total 34 6405 5043 578 784
===============================================================================
$ cargo bloat --crates -n 100
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
Analyzing target/debug/bcachefs
File .text Size Crate
3.7% 31.4% 1.1MiB [Unknown]
3.6% 30.2% 1.1MiB clap_builder
1.9% 16.1% 584.0KiB std
0.7% 5.9% 215.4KiB clap_complete
0.3% 2.8% 100.3KiB env_logger
0.3% 2.3% 82.4KiB bcachefs
0.2% 1.5% 53.1KiB anyhow
0.1% 1.1% 39.0KiB bch_bindgen
0.1% 0.9% 33.4KiB strsim
0.1% 0.9% 33.1KiB termcolor
0.1% 0.7% 26.2KiB clap_lex
0.1% 0.6% 22.7KiB uuid
0.1% 0.5% 19.5KiB rtoolbox
0.1% 0.5% 19.1KiB anstream
0.0% 0.3% 12.3KiB rpassword
0.0% 0.3% 12.3KiB rustix
0.0% 0.2% 8.9KiB log
0.0% 0.2% 8.2KiB anstyle
0.0% 0.2% 7.9KiB udev
0.0% 0.1% 5.4KiB bitflags
0.0% 0.1% 4.6KiB zeroize
0.0% 0.1% 3.6KiB errno
0.0% 0.0% 1.5KiB terminal_size
0.0% 0.0% 1.1KiB utf8parse
0.0% 0.0% 1.0KiB colorchoice
0.0% 0.0% 575B byteorder
0.0% 0.0% 541B anstyle_parse
0.0% 0.0% 435B memchr
0.0% 0.0% 18B anstyle_query
11.8% 100.0% 3.6MiB .text section size, the file size is 30.1MiB
Note: numbers above are a result of guesswork. They are not 100% correct and never will be. |
Release build numbers, probably more useful to consider: $ cargo bloat --release --crates -n 100
Finished `release` profile [optimized] target(s) in 0.06s
Analyzing target/release/bcachefs
File .text Size Crate
8.2% 52.1% 1.1MiB [Unknown]
2.7% 17.4% 380.5KiB std
2.6% 16.7% 365.8KiB clap_builder
0.8% 5.2% 113.5KiB clap_complete
0.7% 4.2% 91.6KiB bcachefs
0.2% 1.1% 25.1KiB env_logger
0.1% 0.4% 9.7KiB anyhow
0.0% 0.3% 5.6KiB bch_bindgen
0.0% 0.2% 4.4KiB uuid
0.0% 0.1% 2.9KiB clap_lex
0.0% 0.1% 2.8KiB rpassword
0.0% 0.1% 2.5KiB anstyle
0.0% 0.1% 2.0KiB strsim
0.0% 0.1% 1.6KiB anstream
0.0% 0.1% 1.6KiB udev
0.0% 0.1% 1.1KiB log
0.0% 0.0% 942B zeroize
0.0% 0.0% 826B errno
0.0% 0.0% 749B termcolor
0.0% 0.0% 688B rtoolbox
0.0% 0.0% 435B memchr
0.0% 0.0% 227B terminal_size
0.0% 0.0% 8B colorchoice
15.7% 100.0% 2.1MiB .text section size, the file size is 13.7MiB
Note: numbers above are a result of guesswork. They are not 100% correct and never will be. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gives more control over the logging by also allowing log level control through environment variable e.g.
BCACHEFS_LOG=trace
. This is useful in some contexts where it's more difficult to change the CLI argument than it is to change the environment. Also useful for CI to centrally set the logging to be verbose.Beyond that, also stop using
std::process:exit()
in favor ofExitCode
for better error printing.